package com.zzs.client.dao.redis;

import com.zzs.common.core.constant.RedisKeyConsts;
import com.zzs.common.core.entity.redis.CodeSubmitCache;
import com.zzs.common.redis.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author zzs
 * @date 2025/04/13
 */
@Component
public class CodeSubmitCacheManager {
    @Autowired
    private RedisService redisService;

    public CodeSubmitCache getCodeSubmitCache(long codeSubmitId) {
        return redisService.getValue(RedisKeyConsts.getCodeSubmitKey(codeSubmitId), CodeSubmitCache.class);
    }

    public void save(CodeSubmitCache codeSubmitCache) {
        redisService.saveValue(RedisKeyConsts.getCodeSubmitKey(codeSubmitCache.getId()), codeSubmitCache, RedisKeyConsts.getCodeSubmitExpireTime(), RedisKeyConsts.getCodeSubmitTimeUnit());
    }
}
